﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WebStudio.Framework.Helper
{
    public class EnumHelper
    {
        /// <summary>
        /// 获取枚举列表
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static List<KeyValuePair<int,string>> GetEnumStringList<T>()
        {
            var resultPrepare = Enum.GetNames(typeof(T));
            List<KeyValuePair<int, string>> result = new List<KeyValuePair<int, string>>();

            Array.ForEach(resultPrepare,
                          f => result.Add(new KeyValuePair<int, string>((int)(Enum.Parse(typeof(T), f)), ResourceHelper.LocalizeEnumeration(Enum.Parse(typeof(T), f)))
            ));

            return result;
        }
    }
}
